<template>
    <div class="default-main ba-table-box">
        <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />

        <!-- 表格顶部菜单 -->
        <TableHeader :buttons="['refresh', 'comSearch', 'quickSearch', 'columnDisplay']"
            quick-search-placeholder="根据分类名称模糊查询" />
        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table />

        <PopupForm ref="formRef" />
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted, provide } from 'vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'
import { defaultOptButtons } from '/@/components/table'
import PopupForm from './popupForm.vue'
import { useI18n } from 'vue-i18n'
import { baTableApi } from '/@/api/common'
import baTableClass from '/@/utils/baTable'

defineOptions({
    name: 'article/index',
})

const { t } = useI18n()
const tableRef = ref()
const baTable = new baTableClass(
    new baTableApi('/admin/v1/page/order/'),
    {
        dblClickNotEditColumn: ['all'],
        column: [
            { type: 'selection', align: 'center', operator: false },
            { label: 'ID', prop: 'id', align: 'center', operator: false, },
            { label: '订单号', prop: 'order_sn', align: 'center', operator: 'LIKE', operatorPlaceholder: '请输入订单号' },
            { label: '用户', prop: 'user.username', align: 'center',  operator: false },
            { label: '订单总金额', prop: 'order_amount', align: 'center',operator: false, },
            { label: '实付金额', prop: 'pay_fee', align: 'center',operator: false,  },
            { label: '优惠卷抵扣金额', prop: 'coupon_discount_fee', align: 'center',operator: false, },
            { label: '支付方式', prop: 'pay_mode', align: 'center',operator: false, },
            { label: '支付模块', prop: 'module_name', align: 'center',operator: false, },
            { label: '状态', prop: 'status_name', align: 'center',operator: false, },
       
            {
                label:'创建时间',
                prop: 'create_time',
                align: 'center',
                render: 'datetime',
                sortable: 'custom',
                operator: false,
            }
        ],
    },
    {
        defaultItems: {
            status: 1,
        },
    }
)

provide('baTable', baTable)

onMounted(() => {
    baTable.table.ref = tableRef.value
    baTable.mount()
    baTable.getIndex()?.then(() => {
        baTable.dragSort()
    })
})
</script>

<style scoped lang="scss"></style>
